<template>
  <div class="overlay">
    <van-icon name="close" class="i-close" @click="close" color="red" size="25"/>
    <van-swipe vertical class="full-width-height" v-if="mediaType=='img'">
      <van-swipe-item v-for="(image, index) in czzyImages" :key="index">
        <img v-lazy="image" class="full-width-height"/>
      </van-swipe-item>
    </van-swipe>
    <video v-else :src="czzyImages" class="full-width-height" type="video/mp4" autoplay controls>
      您的浏览器不支持 video 标签。
    </video>
  </div>
</template>

<script>
export default {
  name: 'Overlay',
  props: {
    mediaType: {
      type: String,
      default: 'img'
    },
    czzyImages: {
      type: [Array, String]
    }
  },
  methods: {
    close() {
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" scoped>
.overlay {
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, .7);
  z-index: 200;

  .i-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
  }

  .full-width-height {
    width: 100%;
    height: 100%;
  }
}
</style>
